package CtrLayer;
import java.sql.Date;
import java.util.ArrayList;

import ModelLayer.*;
import DBLayer.*;


public class CtrEmployee {
	private IFDBEmployee dbEmp;

	public CtrEmployee(){
		dbEmp = DBEmployee.getInstance();
	}
	
	public ArrayList<Employee> getAllEmployees(){
		return dbEmp.getAllEmployees();
	}
	
	public int login(String username, String password){
		return dbEmp.login(username, password);
	}
	
	public Employee getEmployee_byEmployeeID(int pid){
		return dbEmp.getEmployee_byEmployeeID(pid);
	}
	
	public ArrayList<Employee> getAll_where(String wClause){
		return dbEmp.getAll_where(wClause);
	}
	
	public ArrayList<Employee> searchRandom(String searchF) {
		return dbEmp.searchRandom(searchF);
	}
	
	public Employee getEmployee_byName(String name){
		return dbEmp.getEmployee_byName(name);
	}
	
	public ArrayList<Employee> getAllEmployees_byPosition(String position){
		return dbEmp.getAllEmployees_byPosition(position);
	}
	
	public int insert(int pid, String fname, String lname, String address,
			String city, String postalCode, String country, String phone,
			String email, Date regDate, String username, String password, String position,
			double salary){
	
		Employee emp = new Employee(-1,fname,lname,address,city,postalCode,country,phone,email,regDate,username,password,position,salary);
		
		return dbEmp.insert(emp);
	}
	
	public int update(int pid, String fname, String lname, String address,
			String city, String postalCode, String country, String phone,
			String email, Date regDate, String username, String password, String position,
			double salary){
		
		Employee emp = new Employee(pid,fname,lname,address,city,postalCode,country,phone,email,regDate,username,password,position,salary);
		return dbEmp.update(emp);
	}
	
	public int delete(int pid){
		return dbEmp.delete(pid);
	}
	
	public int insert(Employee emp) {
		return dbEmp.insert(emp);
	}
	
	public int update(Employee emp){
		return dbEmp.update(emp);
	}

}
